### ./configure here :-D
CONFIG += qt debug warn_on

#prefix=/usr
prefix=/home/combine/usr
#shared_dir=/usr/share/imagehold/plugins
#home_dir=imagehold // doesn't work for now

kde {
#	KDE_DIR=$$system(kde-config --prefix)
	KDE_DIR=$$system(kde-config --localprefix)
}

COMPILE_DEST = $$PWD/bin

unix {
	isEmpty(shared_dir) {
		shared_dir = share/imagehold
	}
#	DEFINES += SHARED_DIR=\\\"$$prefix/share/imagehold\\\"
#	translations.path = $$prefix/share/imagehold
#	} else {
	DEFINES += SHARED_DIR=QCoreApplication::applicationDirPath\\\(\\\)+\\\"/../$$shared_dir\\\"
	translations.path = $$prefix/$$shared_dir
#	}
	count(plugins_dir, 1) {
		DEFINES += PLUGINS_DIR=\\\"$$plugins_dir\\\"
	}
}


plugin {
	DESTDIR = $$COMPILE_DEST/plugins
	PACKAGE_BUILD_PATH = $$PWD/build/plugins
	unix:isEmpty(plugins_dir) {
		TARGET_PATH = $$prefix/$$shared_dir/plugins
	} else {
		TARGET_PATH = $$plugins_dir
	}
} else {
	DESTDIR = $$COMPILE_DEST
	PACKAGE_BUILD_PATH = $$PWD/build
	unix {
		TARGET_PATH = $$prefix/bin
	}
}

MOC_DIR = $$PACKAGE_BUILD_PATH/moc
RCC_DIR = $$PACKAGE_BUILD_PATH/rcc
UI_DIR = $$PACKAGE_BUILD_PATH/ui
macx {
	OBJECTS_DIR = $$PACKAGE_BUILD_PATH/obj/macx
}
unix {
	OBJECTS_DIR = $$PACKAGE_BUILD_PATH/obj/unix
	target.path += $$TARGET_PATH
	INSTALLS += target
}
win32 {
	OBJECTS_DIR = $$PACKAGE_BUILD_PATH/obj/win32
}




isEmpty(QMAKE_LRELEASE) {
	win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
	else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(QMAKE_LUPDATE) {
        win32:QMAKE_LUPDATE = $$[QT_INSTALL_BINS]\lupdate.exe
	else:QMAKE_LUPDATE = $$[QT_INSTALL_BINS]/lupdate
}

# this is the way to add anything to Makefile
#PRO_FILE = $$basename(PWD).pro
uptranslate.input = _PRO_FILE_
uptranslate.output = lupdate #usually the filename(s). actually the target
#uptranslate.clean = none
uptranslate.commands = $$QMAKE_LUPDATE ${QMAKE_FILE_IN}
uptranslate.CONFIG += no_link
QMAKE_EXTRA_COMPILERS += uptranslate # very useful,
                        # if input is more then one file.
                        # creates "compiler_uptranslate_make_all" target, ..._make_clean, etc.
                        # In my case not so useful, but still necessary

# create *.qm translation files
translate.input = TRANSLATIONS
translate.output = $$COMPILE_DEST/${QMAKE_FILE_BASE}.qm
translate.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm $$COMPILE_DEST/${QMAKE_FILE_BASE}.qm
translate.clean = none
translate.CONFIG += no_link
translate.depends += lupdate
QMAKE_EXTRA_COMPILERS += translate
POST_TARGETDEPS += compiler_translate_make_all
#POST_TARGETDEPS += translate


#install *.qm translations files
for(trans_file, TRANSLATIONS) {
        curr_file = $$COMPILE_DEST/$$replace(trans_file, .ts, .qm)
	system(touch $$curr_file)
#        QMS += $$curr_file
        translations.files += $$curr_file
}
translations.depends = compiler_translate_make_all
#translations.input = QMS
#translations.extra = -$(COPY_FILE) ${QMAKE_FILE_IN} "$(INSTALL_ROOT)$$translations.path"
INSTALLS += translations

#translate.input = PRO_FILE
##translate.output = lrelease #usually the filename. actually the target
##translate.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN}
##translate.CONFIG += no_link
##QMAKE_EXTRA_COMPILERS += translate
###POST_TARGETDEPS += compiler_uptranslate_make_all
##POST_TARGETDEPS += lrelease
